﻿@model CodeStash.Models.Security.LogOnModel
@{
    ViewBag.Title = "Log On";
}
@section SpecificPageHeadStuff
 {
    @Html.ScriptTag(Url.Content("~/Scripts/Controllers/Account/accountFunctions.js"))
    @Html.ScriptTag(Url.Content("~/Scripts/jquery.validate.min.js"))
    @Html.ScriptTag(Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js"))
}
@using CodeStash.ExtensionsMethods
<h2>
    Log On</h2>
<p>
    You may login by choosing your OpenId Provider, or by entering your CodeStash username
    and password.
</p>
<p>    
    Or you can @Html.ActionLink("Register", "Register")
    if you don't have an account.
</p>
<form action="Authenticate?ReturnUrl=@HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"])" 
        method="post" id="openid_form">
    <input type="hidden" name="action" value="verify" />
    <div class="logonBox">
        <fieldset>
            <legend>Login using OpenID</legend>
            <div class="openid_choice">
                <p>
                    Please click your account provider:</p>
                <div id="openid_btns">
                </div>
            </div>
            <div id="openid_input_area">
                @Html.TextBox("openid_identifier")
                <input type="submit" value="Log On" />
            </div>
            <noscript>
                <p>
                    OpenID is service that allows you to log-on to many different websites using a single
                    indentity. Find out <a href="http://openid.net/what/">more about OpenID</a> and
                    <a href="http://openid.net/get/">how to get an OpenID enabled account</a>.</p>
            </noscript>
            <div>
                @if (Model != null)
                {
                    if (String.IsNullOrEmpty(Model.UserName))
                    {
                    <div class="editor-label">
                        @Html.LabelFor(model => model.OpenID)
                    </div>
                    <div class="editor-field">
                        @Html.DisplayFor(model => model.OpenID)
                    </div>
                    <p class="button">
                        @Html.ActionLink("New User ,Register", "Register", new { OpenID = Model.OpenID })
                    </p>
                    }
                }
            </div>
        </fieldset>
    </div>
</form>
@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
@using (Html.BeginForm("Logon", "Account", FormMethod.Post, new { id = "LogonForm" }))
{

    @Html.AntiForgeryToken("LogOn")
    
    <div class="logonBox">
        <fieldset>
            <legend>Or Login Normally</legend>
            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName, new { style = "width:300px" })
                @Html.ValidationMessageFor(m => m.UserName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password, new { style = "width:300px" })
                @Html.ValidationMessageFor(m => m.Password)
            </div>
            <div class="editor-label">
                @Html.CheckBoxFor(m => m.RememberMe, new { style = "float:left" })
                <label for="RememberMe" class="centerAlignedText">Remember me?</label>
            </div>
            <p>
                <br />
                <input id="LogOnBtn" type="submit" value="Log On" />
                <br />
            </p>
        </fieldset>
    </div>
}
